﻿using System;
using System.Web;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.Web.UI.WebControls;
using System.Data;
using System.Collections.Generic;
using System.Collections;
using System.ComponentModel;
using Microsoft.Web.Preview.Services;
using BLL.WWW_User.User;
using Model.WWW_User.User;
using BLF.WWW_User.Users;
using BLF.WWW_User.UserComments;
using Model;
using Lx.Web.Common.UI;
using Lx.Web.Common.ControlsUI;
using System.Text;
using System.Xml;
using System.IO;


namespace WebServices
{

    /// <summary>
    /// Summary description for FeedBack
    /// </summary>
    [WebService(Namespace = "http://www.italki.com/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    [System.Web.Script.Services.ScriptService]
    public class My : System.Web.Services.WebService
    {
        [WebMethod]
        public ArrayList GetAllComment(string memberNo, int pageIndex, int pageSize)
        {
            ArrayList obj = UserComments.GetAllComments(memberNo, pageIndex, pageSize);
            return obj;
        }
        [WebMethod]
        public bool DeleteComment(string id)
        {
           return  UserComments.DeleteComment(id);
          
        }
        [WebMethod]
        public bool UpdateOnlineStatus(string memberNo, string status)
        {
            return BLF.WWW_User.Users.User.UpdateOnlineStatus(memberNo, status);
        }
        [WebMethod]
        public bool UpdateNotifications(string memberNo,int count, int count1)
        {
            return BLF.WWW_User.Users.User.UpdateUserNotifi(memberNo, count, count1);
        }
        [WebMethod]
        public bool UpdatePriacyLoved(string memberNo, string privacyAgreeFriend, string privacyDetailProfile, string privacyContactInfo, string privactLinkMan, string WhoViewComment, string WhoAddComment, string WhoChatMe, string WhoMsg, string AllowInvite)
        {
            char[] pl = new char[]{
                char.Parse(privacyAgreeFriend),
                char.Parse(privacyDetailProfile),
                char.Parse(privacyContactInfo),
                char.Parse(privactLinkMan),
                char.Parse(WhoViewComment),
                char.Parse(WhoAddComment),
                char.Parse(WhoChatMe),
                char.Parse(WhoMsg),
                char.Parse(AllowInvite)
                };

            return BLF.WWW_User.Users.User.UpdatePriacyLoved(memberNo, pl);
        }
        [WebMethod]
        public bool UpdateGeneSet(String MemberNo, string SiteLanguages, string TimeZone)
        {

            return BLF.WWW_User.Users.User.UpdateGeneSet(MemberNo, SiteLanguages, TimeZone);
             
        }
        [WebMethod]
         public ArrayList UpdatePwd(string memberNo, string pwd,string oldPwd)
        {
           ArrayList obj=new ArrayList();
           string bum ;
           bool i = false;
           bool a = false;
           bum = BLF.WWW_User.Users.User.GetUserPws(memberNo);
           if (Globals.Enctype(oldPwd.Trim())== bum.Trim())
           {
               i = true;
           }
            if(i)
            {
                a = BLF.WWW_User.Users.User.UpdatePwd(memberNo, Globals.Enctype(pwd.Trim()));
            }

           obj.Add(i);
           obj.Add(a);
            return obj;
        }
        [WebMethod]
        public bool UpdateMyPwd(string memberNo,string pwd)
        { 
           return BLF.WWW_User.Users.User.UpdatePwd(memberNo, Globals.Enctype(pwd.Trim()));
        }
        [WebMethod]
        public bool UpdateIM(string memberNo, string IM1Account, string IM2Account, string IM3Account, string IM4Account, string IM5Account, string IM6Account)
        {
            string[] im = new string[]{
                IM1Account==null?"":IM1Account.Trim(),
                IM2Account==null?"":IM2Account.Trim(),
                IM3Account==null?"":IM3Account.Trim(),
                IM4Account==null?"":IM4Account.Trim(),
                IM5Account==null?"":IM5Account.Trim(),
                IM6Account==null?"":IM6Account.Trim()
            };
            return BLF.WWW_User.Users.User.UpdateIM(memberNo, im);
        }
        [WebMethod]
        public bool UpdateUserStudyProfile(String memberno, Int32 eCP, Int32 favorite, Int32 mwy, Int32 languageOption, String targetLanguage,String targetLanguageLevel, String motherTongue, String motherTongueLevel, String motherTongue2, String motherTongue2Level,String motherTongue3, String motherTongue3Level, String motherTongue4, String motherTongue4Level, String targetLanguage2, String targetLanguage2Level, String targetLanguage3,String targetLanguage3Level, String targetLanguage4, String targetLanguage4Level)
        {

            return BLF.WWW_User.Users.User.UpdateUserStudyProfile(memberno,eCP,favorite,mwy, languageOption, targetLanguage, targetLanguageLevel,motherTongue, motherTongueLevel, motherTongue2,motherTongue2Level, motherTongue3, motherTongue3Level, motherTongue4, motherTongue4Level, targetLanguage2, targetLanguage2Level, targetLanguage3, targetLanguage3Level,targetLanguage4, targetLanguage4Level);
        }
        [WebMethod]
        public bool UpdateUserPersProf(String memberno, String nickname, String firstName, String lastName, String gender,
           DateTime bOD, String country, String city, String nationality, String hometown, String marriage, String occupationCat,
           String occupation, String education, String blog, String personalWebpage, String interest, String favoriteBooks,
           String favoriteMovies, String favoriteMusic, String timezone, String introduction)
        {

            return BLF.WWW_User.Users.User.UpdateUserPersProf(memberno, nickname, firstName, lastName, gender, bOD, country, city, nationality, hometown, marriage, occupationCat, occupation, education, blog, personalWebpage, interest, favoriteBooks, favoriteMovies, favoriteMusic, timezone, introduction);
        }
        [WebMethod]
        public ArrayList GetLinkManUserInfo(string memberNo, int pageIndex, int pageSize)
        {
            ArrayList obj = BLF.WWW_WWW.Contact.Contacts.GetLinkManUserInfo(memberNo, pageIndex, pageSize);
            return obj;
        }
        [WebMethod]
        public ArrayList GetUserEvent(string memberNo)
        {
            ArrayList ob = new ArrayList();
            List<UserEvents> obj = BLF.WWW_User.Users.User.GetUserEvent(memberNo);
            List<string> ls = new List<string>();
            List<int> i = new List<int>();
            foreach (UserEvents us in obj)
            {
                i.Add(us.EventID);
                ls.Add(GetUserLastEventDescrip(us.CateID.Trim(), us.VarReplace));

            }
            ob.Add(ls);
            ob.Add(i);
            return ob;
        }
        /// <summary>
        /// 删除更新的内容
        /// </summary>
        /// <param name="id">更新的内容ID</param>
        /// <returns>bool</returns>
        [WebMethod]
        public bool DelUserEvent(string id)
        {
            return BLF.WWW_User.Users.User.DelUserEvent(id);

        }
        /// <summary>
        /// 在小黑板上面留言
        /// </summary>
        /// <param name="userTo">留言者</param>
        /// <param name="userFrom">得到留言的人</param>
        /// <param name="content">留言内容</param>
        /// <returns>Bool</returns>
        [WebMethod]
       
         public bool AddComment(string userTo, string userFrom, string content)
        {
            return UserComments.AddComment(userTo, userFrom, HttpUtility.HtmlEncode(content));
           
           
        }
        [WebMethod]
        public bool SenCommentMail(string userTo, string userFrom)
        {
            
                string nickName = "";
                int emailOption = 0;
                bool se = false;
                UserModel bumUserTo = BLF.WWW_User.Users.User.GetOherInfo(userTo, userFrom, out nickName, out emailOption);
                if (bumUserTo != null)
                {

                    string FromName = nickName;
                    string FromID = userFrom;
                    string ToName = bumUserTo.Nickname;
                    string ToID = bumUserTo.MemberNo;
                    string ToEmail = bumUserTo.MemberEmail;
                    string ToLng = "en-us";
                    if (bumUserTo.BaseLanguage != null)
                    {
                        if (bumUserTo.BaseLanguage.Trim() != "") ToLng = bumUserTo.BaseLanguage.Trim();
                    }

                    Int32 emailVal = emailOption;
                    if ((4 & emailVal) == 4)
                    {

                        string eSubject = Globals.ReadTextByXmlNode(FormatFileName(Server.MapPath(String.Format("/Template/emailxml/{0}/Comment.xml", ToLng)), ToLng), "email", "subject", "");
                        string eBody = Globals.ReadTextByXmlNode(FormatFileName(Server.MapPath(String.Format("/Template/emailxml/{0}/Comment.xml", ToLng)), ToLng), "email", "body", "");
                        eSubject = eSubject.Replace("{0}", FromName);
                        eBody = eBody.Replace("{0}", FromName).Replace("{1}", ToName).Replace("{2}", FromID);
                        if (System.Text.RegularExpressions.Regex.IsMatch(ToEmail, "\\w+([-+.']\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*"))
                        {
                            se = MsMailSend.SendMail(eSubject, eBody, ToEmail, null, true);
                        }

                    }

                }
                return se;
           
        }
        [WebMethod]
        public bool GetMypwd(string memberCrtNo)
        {
            UserModel bum = BLF.WWW_User.Users.User.GetDetailUserInfo2(memberCrtNo);
            
                if (bum != null&&bum.MemberCrtNo != null && bum.MemberCrtNo != "")
                {
                    string link = System.Configuration.ConfigurationManager.AppSettings["LoginHost"] + "/user/resetmypassword.htm?AffirmNo=" + Globals.Enctype(bum.AffirmNo) + "&MemberNo=" + bum.MemberNo;
                    string subject = Globals.ReadTextByXmlNode(FormatFileName(Server.MapPath(String.Format("/Template/emailxml/{0}/PasswordReset.xml", Globals.Language))), "email", "subject", "");
                    string body = Globals.ReadTextByXmlNode(FormatFileName(Server.MapPath(String.Format("/Template/emailxml/{0}/PasswordReset.xml", Globals.Language))), "email", "body", "");
                    MsMailSend.SendMail(subject, body.Replace("$$link$$", link).Replace("$$NickName$$", bum.Nickname), bum.MemberEmail, null, true);
                    return true;
                }
                else
                {
                    return false;
                }
            
           
        }

        /// <summary>
        /// 注册
        /// </summary>
        /// <param name="user">注册的模板</param>
        /// <param name="us">输出UserModel</param>
        /// <returns>string的其中为-1的时候为出错，0为该邮箱以注册过，其次就是会员号</returns>
         [WebMethod]
        public ArrayList Register(String motherTongue, String targetLanguage, String country, String timezone, String memberEmail, String password, String nickname, String gender, string bOD, String Ref, string Code)
        {
            ArrayList ob = new ArrayList();
            string re = "1";
            UserModel bum = null;
            if (HttpContext.Current.Request.Cookies["ImageValidateCode"].Value == Code)
            {
                RegiUserModel user = new RegiUserModel(motherTongue, "5", targetLanguage, "0", 3, country, timezone, memberEmail, Globals.Enctype(password.Trim()), nickname, gender, bOD == "" ? DateTime.Parse("1900-1-1") :DateTime.Parse(bOD), Globals.Language, Ref);
                re = BLF.WWW_User.Users.User.Register(user, out bum);
            }
            ob.Add(re);
            ob.Add(bum);
            return ob;
        }
        [WebMethod]
        public void SendRe(string nickname, string memberCrtNo, string affirmNo, string memberNo)
        {


            if (affirmNo != null && affirmNo != "")
            {
                string link = System.Configuration.ConfigurationManager.AppSettings["LoginHost"] + "/user/confirm.htm?MemberNo=" + memberNo + "&AffirmNo=" + Globals.Enctype(affirmNo);
                string subject = Globals.ReadTextByXmlNode(FormatFileName(Server.MapPath(String.Format("/Template/emailxml/{0}/Welcome.xml", Globals.Language))), "email", "subject", "");
                string body = Globals.ReadTextByXmlNode(FormatFileName(Server.MapPath(String.Format("/Template/emailxml/{0}/Welcome.xml", Globals.Language))), "email", "body", "");
                if (System.Text.RegularExpressions.Regex.IsMatch(memberCrtNo, "\\w+([-+.']\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*"))
                {
                    MsMailSend.SendMail(subject, body.Replace("$$link$$", link).Replace("$$NickName$$", nickname), memberCrtNo, null, true);
                }
            }
        }
        [WebMethod]
        public bool Send(string memberNo)
        {
            UserModel bum = BLF.WWW_User.Users.User.GetDetailUserInfo(memberNo);
            if (bum.AffirmNo != null && bum.AffirmNo != "")
            {
                string link = System.Configuration.ConfigurationManager.AppSettings["LoginHost"] + "/user/confirm.htm?MemberNo=" + bum.MemberNo + "&AffirmNo=" + Globals.Enctype(bum.AffirmNo);
                string subject = Globals.ReadTextByXmlNode(FormatFileName(Server.MapPath(String.Format("/Template/emailxml/{0}/Welcome.xml", Globals.Language))), "email", "subject", "");
                string body = Globals.ReadTextByXmlNode(FormatFileName(Server.MapPath(String.Format("/Template/emailxml/{0}/Welcome.xml", Globals.Language))), "email", "body", "");
                if (System.Text.RegularExpressions.Regex.IsMatch(bum.MemberEmail, "\\w+([-+.']\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*"))
                {
                    return MsMailSend.SendMail(subject, body.Replace("$$link$$", link).Replace("$$NickName$$", bum.Nickname), bum.MemberEmail, null, true);
                }
                return false;
            }
            else {
                return false;
            }
        }
        [WebMethod]
        public bool UpdateUserTeachProfile(string memberno, int languageOption, string teachLanguage, string teachLanguageLevel, string hourly_rates)
        {
            return BLF.WWW_User.Users.User.UpdateUserTeachProfile(memberno, languageOption, teachLanguage, teachLanguageLevel, Convert.ToDecimal(hourly_rates == "" ? "0" : hourly_rates));
        }
        [WebMethod]
        public ArrayList GetMyQuestion(string memberno)
        {
            ArrayList ob = new ArrayList();
            int recordCount = 0;
            ob.Add(BLF.WWW_WWW.Answer.Answers.GetMyQuestion(memberno, out recordCount));
            ob.Add(recordCount);
            return ob;
        }
        [WebMethod]
        public ArrayList GetMyDoc(string memberno)
        {
            ArrayList ob = new ArrayList();
            int recordCount = 0;
            ob.Add(BLF.WWW_WWW.Files.Files.GetMyDoc(memberno, out recordCount));
            ob.Add(recordCount);
            return ob;
        }
        /// <summary>
        ///  导出Email联系人
        /// </summary>
        /// <param name="userName">email</param>
        /// <param name="emcom">email后缀</param>
        /// <param name="userPwd">密码</param>
        /// <returns>ArrayList 0邮箱登陆情况，1List(UserModel),2多少条数据</returns>
        [WebMethod]
        public ArrayList GetLinkMan(string userName,string emcom, string userPwd)
        {
            ArrayList ob = new ArrayList();
            List<InviteUserModel> maiList = null;
            List<InviteUserModel> su = null;
            int b= 0;
            string a = "";
            if (emcom == "@gmail.com")
            {
                a = BLF.EmailInvite.Gmail.GetLinkMan(userName + emcom, userPwd, out maiList); 
            }
            ob.Add(a);
            if (maiList != null)
            {
                su = BLF.WWW_User.Users.User.GetUserList(maiList);
                foreach (InviteUserModel um in su)
                {
                    for (int i = 0; i < maiList.Count; i++)
                    {
                        if (maiList[i].MemberCrtNo == um.MemberCrtNo)
                        {
                            maiList.RemoveAt(i);
                        }
                    }
                }
                su.AddRange(maiList);
                b = maiList.Count;                                                                                                                                   
            }
            ob.Add(su);
            ob.Add(b);
            return ob;
        }
        [WebMethod]
        public ArrayList GetMyGroup(string memberno)
        {
            ArrayList ob = new ArrayList();
            int recordCount = 0;
            ob.Add(BLF.WWW_WWW.Group.Group.GetMyGroup(memberno, out recordCount));
            ob.Add(recordCount);
            return ob;
        }
        [WebMethod]
        public ArrayList GetMyKnowledges(string memberno)
        {
            ArrayList ob = new ArrayList();
            int recordCount = 0;
            ob.Add(BLF.WWW_WWW.Wiki.Wiki.GetMyKnowledges(memberno, out recordCount));
            ob.Add(recordCount);
            return ob;
        }
        [WebMethod]
        public string SenLinkMan(string sendTname, string sedWname, string memberno, string rname)
        {
            string idd = "";
            if (sendTname != "")
            {
                idd = BLF.WWW_User.Users.User.SendFriend(memberno, sendTname).ToString();
            }
            string[] namemail = sedWname.Split(',');
            int nmLength = namemail.Length;


            if (nmLength != 0)
            {
                string rSubject = Globals.ReadTextByXmlNode(FormatFileName(Server.MapPath(String.Format("/Template/emailxml/{0}/Forward.xml", Globals.Language))), "email", "subject", "");
                string rBody = Globals.ReadTextByXmlNode(FormatFileName(Server.MapPath(String.Format("/Template/emailxml/{0}/Forward.xml", Globals.Language))), "email", "body", "");
                for (int i = 0; i < nmLength; i++)
                {
                    if (System.Text.RegularExpressions.Regex.IsMatch(namemail[i], "\\w+([-+.']\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*"))
                    {
                        idd += MsMailSend.SendMail(rSubject.Replace("$$NickName$$", rname), rBody.Replace("$$Email$$", namemail[i].Trim()).Replace("$$NickName$$", rname).Replace("$$MemberNo$$", memberno).Replace("$$FriendName$$", ""), namemail[i].Trim(), null, true).ToString();
                    }

                }
            }
            return idd;
        }
        [WebMethod]
        public ArrayList UpdateEmail(string memberno, string email)
        {
            ArrayList outList=new ArrayList();
            outList.Add(BLF.WWW_User.Users.User.SetEmail(memberno, email));
            email=email.Substring(email.IndexOf("@")+1);
            outList.Add(GetEmailImg(email));
            return outList;
        }
        
        /// <summary>
        /// 验证邮件是否注册了。
        /// </summary>
        /// <param name="email">邮件地址</param>
        /// <returns>int 0为没注册，1为注册了，2为出错</returns>
        [WebMethod]
        public int ValiEmail(string email)
        {
          return BLF.WWW_User.Users.User.ValiEmail(email);
        }
        [WebMethod]
        /// <summary>
        /// 验证密码并申请修改email
        /// </summary>
        /// <param name="pwd">密码</param>
        /// <param name="newemail">新Email</param>
        /// <returns></returns>
        public bool ValiPws(string pwd, string newemail)
        {
            string memberno="";
            memberno= HttpContext.Current.User.Identity.Name;
            ArrayList outList = new ArrayList();
            if (memberno != "" || !System.Text.RegularExpressions.Regex.IsMatch(newemail, "\\w+([-+.']\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*"))
            {

                if (BLF.WWW_User.Users.User.ValiPws(memberno, Globals.Enctype(pwd.Trim()), newemail, out outList))
                {
                    if (outList.Count==3)
                    {
                        string link = System.Configuration.ConfigurationManager.AppSettings["LoginHost"] + "/user/ConfirmEmail.htm?MemberNo=" + memberno + "&nemail=" + newemail + "&AffirmNo=" + Globals.Enctype(outList[2].ToString());
                        string subject = Globals.ReadTextByXmlNode(FormatFileName(Server.MapPath(String.Format("/Template/emailxml/{0}/NewEmail.xml", Globals.Language))), "email", "subject", "");
                        string body = Globals.ReadTextByXmlNode(FormatFileName(Server.MapPath(String.Format("/Template/emailxml/{0}/NewEmail.xml",Globals.Language))), "email", "body", "");
                        MsMailSend.SendMail(subject, body.Replace("$$link$$", link).Replace("$$NickName$$", outList[0].ToString()), newemail, null, true);
                    }
                    return true;
                }
                return false;
            }
            else
            {
                return false;
            }
        }
        public string FormatFileName(string filename, string replaceLang)
        {
            if (!File.Exists(filename))
            {
                filename = filename.Replace("\\" + replaceLang + "\\", "\\en-us\\");
            }
            return filename;
        }
        public string FormatFileName(string filename)
        {
            if (!File.Exists(filename))
            {
                filename = filename.Replace("\\" + Lx.Web.Common.UI.Globals.Language + "\\", "\\en-us\\");
            }
            return filename;
        }


        protected String GetUserLastEventDescrip(String CateId, String VarReplace)
        {

            if (CateId != null && VarReplace != null)
            {
                String[] StrArray = VarReplace.Split('\n');
                if (StrArray != null)
                {
                    return Lx.Web.Common.Resource.GetText(Globals.Language, CateId.Trim(), StrArray);
                }
                else
                {
                    return "";
                }
            }
            return "";
        }
        public string GetEmailImg(string selectValue)
        {
            DataSet ds = new DataSet();
            ds.ReadXml(Server.MapPath(String.Format("/Control/{0}", "EmailUrl.xml")));
            DataTable dt = ds.Tables[0];
            return GetTextFromDT(dt, selectValue);
        }
        private string GetTextFromDT(DataTable dt, string value)
        {
            foreach (DataRow dr in dt.Rows)
            {
                if (dr[0].ToString().ToLower() == value.ToLower())
                {
                    return dr[1].ToString();
                }
            }
            return "";
        }

        #region hui
        /// <summary>
        /// 修改个人档案信息
        /// </summary>
        /// <param name="nickname">昵称</param>
        /// <param name="nationality">国籍</param>
        /// <param name="hometown">家乡</param>
        /// <param name="country">所在国家</param>
        /// <param name="city">所在城市</param>
        /// <param name="gender">性别</param>
        /// <param name="bOD">出生日期</param>
        /// <param name="isShowBod">是否显示年龄（1为显示，0为不显示 默认1）</param>
        /// <param name="introduction">自我介绍</param>
        /// <param name="firstName">姓</param>
        /// <param name="lastName">名</param>
        /// <param name="education">教育程度</param>
        /// <param name="occupation">职业</param>
        /// <param name="occupationCat">职业类别</param>
        /// <param name="personalWebpage">个人主页</param>
        /// <param name="marriage">婚否</param>
        /// <param name="favorite">爱好</param>
        /// <returns></returns>   
        [WebMethod]
        public CommonMessage UpdatePersonalProf(string nickname, string nationality, string hometown, string country, string city, string gender, DateTime bOD
            , bool isShowBod, string introduction, string education, string occupationCat, string occupation, string personalWebpage, string marriage, int favorite, String Week, string FromTime, string ToTime, string timezone)
        {
            if (HttpContext.Current.User.Identity.Name == "")
            {
                return new CommonMessage();
            }
            UpdateUserModel um = new UpdateUserModel();
            um.MemberNo = HttpContext.Current.User.Identity.Name;
            um.Nickname = nickname;
            um.Nationality = nationality;
            um.Hometown = hometown;
            um.Country = country;
            um.City = city;
            um.Gender = gender;
            um.BOD = bOD;
            um.IsShowBod = isShowBod;
            um.Introduction = introduction;
            //um.FirstName = firstName;
            //um.LastName = lastName;
            um.Education = education;
            um.Occupation = occupation;
            um.OccupationCat = occupationCat;
            um.PersonalWebpage = personalWebpage;
            um.Marriage = marriage;
            um.Favorite = favorite;
            um.Timezone = timezone;
            return BLF.WWW_User.Users.User.UpdatePersonalProf(um, Week, FromTime, ToTime);
        }

        /// <summary>
        /// 根新用户语言相关信息
        /// </summary>
        [WebMethod]
        public Model.CommonMessage UpdateStuLanProf(string m1, string m2, string m3, string m4, string ml2, string ml3, string ml4, string t1
            , string t2, string t3, string t4, string tl1, string tl2, string tl3, string tl4)
        {
            if (HttpContext.Current.User.Identity.Name == "")
            {
                return new CommonMessage();
            }
            UserLanguageBuddySet lan = new UserLanguageBuddySet();
            lan.MemberNo = HttpContext.Current.User.Identity.Name;
            lan.MotherTongue = m1;
            lan.MotherTongue2 = m2;
            lan.MotherTongue3 = m3;
            lan.MotherTongue4 = m4;
            lan.MotherTongue2Level = ml2;
            lan.MotherTongue3Level = ml3;
            lan.MotherTongue4Level = ml4;
            lan.TargetLanguage = t1;
            lan.TargetLanguage2 = t2;
            lan.TargetLanguage3 = t3;
            lan.TargetLanguage4 = t4;
            lan.TargetLanguageLevel = tl1;
            lan.TargetLanguage2Level = tl2;
            lan.TargetLanguage3Level = tl3;
            lan.TargetLanguage4Level = tl4;
            return BLF.WWW_User.Users.User.UpdateStuLanProf(lan);
        }
        /// <summary>
        /// 更新教师语言信息
        /// </summary>
        [WebMethod]
        public Model.CommonMessage UpdateTeachLanProf(string tType, string m1, string m2, string m3, string m4, string ml2, string ml3, string ml4, string l1, string l2
            , string l3, string l4, string ll1, string ll2, string ll3, string ll4, string tl1, string tl2, string tl3, string tl4, string tll1
            , string tll2, string tll3, string tll4, string pr, bool frt, string vc, string tz, string wk, string ft, string tt, int changeTime)
        {
            if (HttpContext.Current.User.Identity.Name == "")
            {
                return new CommonMessage();
            }
            Model.WWW_User.Teach.TeachModel tm = new Model.WWW_User.Teach.TeachModel();
            tm.MemberNo = HttpContext.Current.User.Identity.Name;
            tm.TeacherType = tType;
            tm.MotherTongue = m1;
            tm.MotherTongue2 = m2;
            tm.MotherTongue3 = m3;
            tm.MotherTongue4 = m4;
            tm.MotherTongue2Level = ml2;
            tm.MotherTongue3Level = ml3;
            tm.MotherTongue4Level = ml4;
            tm.TargetLanguage = l1;
            tm.TargetLanguage2 = l2;
            tm.TargetLanguage3 = l3;
            tm.TargetLanguage4 = l4;
            tm.TargetLanguageLevel = ll1;
            tm.TargetLanguage2Level = ll2;
            tm.TargetLanguage3Level = ll3;
            tm.TargetLanguage4Level = ll4;
            tm.TLang1 = tl1;
            tm.TLang2 = tl2;
            tm.TLang3 = tl3;
            tm.TLang4 = tl4;
            tm.TLang1Level = tll1;
            tm.TLang2Level = tll2;
            tm.TLang3Level = tll3;
            tm.TLang4Level = tll4;
            tm.Price = decimal.Parse(pr);
            tm.FreeTrial = frt;
            tm.VideoCode = vc;
            tm.Timezone = tz;
            tm.Week = wk;
            tm.FromTime = ft;
            tm.ToTime = tt;
            return BLF.WWW_User.Users.User.UpdateTeachLanProf(tm, changeTime);
        }
        /// <summary>
        /// 根新学生联系方式
        /// </summary>
        [WebMethod]
        public Model.CommonMessage UpdateStuContact(string im1, string im2, string im3, string im4, string im5, string im6)
        {
            //dum.IM1Account;
            //dum.IM2Account;
            //dum.IM3Account;
            //dum.IM4Account;
            //dum.IM5Account;
            //dum.IM6Account;
            //m.Address;
            //um.Address2;
            //.ZipCode;
            //m.Telphone;

            if (HttpContext.Current.User.Identity.Name == "")
            {
                return new CommonMessage();
            }
            DetailUserModel dum = new DetailUserModel();
            dum.MemberNo = HttpContext.Current.User.Identity.Name;
            dum.IM1Account = im1;
            dum.IM2Account = im2;
            dum.IM3Account = im3;
            dum.IM4Account = im4;
            dum.IM5Account = im5;
            dum.IM6Account = im6;
            return BLF.WWW_User.Users.User.UpdateStuContact(dum);
        }
        #endregion

        /// <summary>
        /// 添加留言并获取小黑板列表
        /// 0：int 1有权限留言 0无（注当为1才有后面数据）
        /// 1：小黑板列表 CommentModel List
        /// 2：PageableObject
        /// </summary>        
        [WebMethod]
        public ArrayList AddGetComment(string memberno, int pageIndex, int pageSize, string content)
        {
            string mymemberno = HttpContext.Current.User.Identity.Name;
            if (mymemberno == "")
            {
                return null;
            }
            ArrayList arrList = new ArrayList();
            arrList = UserComments.AddGetComment(memberno, mymemberno, pageIndex, pageSize, HttpUtility.HtmlEncode(content));
            if (arrList != null && (int)arrList[0] == 1)
            {
                BLF.PageableObject objPage = new BLF.PageableObject((int)arrList[2], pageIndex, pageSize);
                arrList.RemoveAt(2);
                arrList.Add(objPage);
            }
            else
            {
                return null;
            }
            return arrList;
        }
        /// <summary>
        /// 删除留言并获取小黑板列表
        /// 0：小黑板列表 CommentModel List
        /// 1：数量
        /// </summary>
        /// <param name="memberno">会员编号</param>
        /// <param name="pageIndex">pageIndex</param>
        /// <param name="pageSize">pageSize</param>
        /// <param name="id">留言id</param>
        /// <returns>ArrayList</returns>
         [WebMethod]
        public ArrayList DeleteGetComment(int pageIndex, int pageSize, int id)
        {
            string memberno= HttpContext.Current.User.Identity.Name;
            if (memberno == "")
            {
                return null;
            }
            ArrayList arrList = new ArrayList();
            arrList = UserComments.DeleteGetComment(memberno, pageIndex, pageSize, id);
            if (arrList != null)
            {
                BLF.PageableObject objPage = new BLF.PageableObject((int)arrList[1], pageIndex, pageSize);
                arrList.RemoveAt(1);
                arrList.Add(objPage);
            }
            return arrList;
        }

        /// <summary>
        /// 添加老师对学生的feedback
        /// </summary>
        [WebMethod]
        public CommonMessage AddTToSDesc(long sid, string desc)
        {
            string memberno=HttpContext.Current.User.Identity.Name;
            if (memberno == "")
            {
                return new CommonMessage();
            }
            return BLF.WWW_User.Users.User.AddTToSDesc(memberno, sid, HttpUtility.HtmlEncode(desc));
        }
        /// <summary>
        /// 修改一些学生必填得资料
        /// </summary>
        /// <param name="memberno">会员号</param>
        /// <param name="TargetLanguage">学习语言</param>
        /// <param name="TargetLanguageLevel">学习语言级别</param>
        /// <param name="Gender">性别</param>
        /// <param name="BOD">年龄</param>
        /// <param name="Country">国家</param>
        /// <param name="IMType">IM类型</param>
        /// <param name="IMValue">IM值</param>
        /// <param name="timezone">时区</param>
        /// <param name="Introduction">介绍</param>
        /// <param name="IsShowBod">是否显示年龄</param>
        /// <returns>bool</returns>
        [WebMethod]
        public bool UpdateStep1(string memberno, string TargetLanguage, string TargetLanguageLevel, string Gender, DateTime BOD, string Country, string IMType, string IMValue, string timezone, string Introduction, bool IsShowBod)
        {
            return BLF.WWW_User.Users.User.UpdateStep1(memberno, TargetLanguage, TargetLanguageLevel, Gender, BOD, Country, IMType, IMValue, timezone, Introduction, IsShowBod);
        }
        /// <summary>
        /// 修改是否显示欢迎页
        /// </summary>
        /// <param name="memberno">会员号</param>
        /// <param name="guide">bool ture显示 false不显示</param>
        /// <returns></returns>
        [WebMethod]
        public void UpdateGuide(string memberno, bool guide)
        {
           BLF.WWW_User.Users.User.UpdateGuide(memberno, guide);
        }
    }

}
